#include <iostream>
#include <cstdio>
#include <vector> 
#include <queue> 

using namespace std; 


int main()
{
	int i, n, a, b, c, d, e; 
	vector<int> k, m; 
	queue<int> q; 
	
	//freopen("p1135.in", "r", stdin); 
	
	cin>>n>>a>>b; 
	k.resize(n+1); 
	m.resize(n+1); 
	
	for (i=1; i<=n; i++) {
		cin>>k[i]; 
		m[i] = -1; 
	}
	
	m[a] = 0; 
	q.push(a); 
	while(!q.empty()) {
		c = q.front(); 
		q.pop(); 
		d = c + k[c]; 
		if (d>=1 && d<=n && m[d]<0) {
			m[d] = m[c]+1; 
			q.push(d); 
		}
		e = c - k[c]; 
		if (e>=1 && e<=n && m[e]<0) {
			m[e] = m[c]+1; 
			q.push(e); 
		}
		if (d==b || e==b)
			break; 
	}
	cout<<m[b]<<endl; 	
	return 0; 
}


